package com.nuoniu.sibanyun.service.production.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nuoniu.sibanyun.entity.production.VProductionPlanDetail;
import com.nuoniu.sibanyun.entity.so.VSaleDeliveryDetail;
import com.nuoniu.sibanyun.mapper.production.VProductionPlanDetailMapper;
import com.nuoniu.sibanyun.service.production.IVProductionPlanDetailService;
import com.nuoniu.sibanyun.userThread.UserInfo;
import com.nuoniu.sibanyun.userThread.UserThreadLocal;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 主生产计划明细 服务实现类
 * </p>
 *
 * @author 小啊刚
 * @since 2021-03-11
 */
@Service
public class VProductionPlanDetailServiceImpl extends ServiceImpl<VProductionPlanDetailMapper, VProductionPlanDetail> implements IVProductionPlanDetailService {

    @Override
    public void updateOperationStatus(Integer voucherId) {
        baseMapper.updateOperationStatus(voucherId);
    }

    @Override
    public Integer getOperationCount(Integer orderId) {
        return baseMapper.getOperationCount(orderId);
    }

    @Override
    public List<VProductionPlanDetail> getList(Integer companyId) {
        return baseMapper.getList(companyId);
    }

    @Override
    public List<VProductionPlanDetail> getDetailsByOrderId(Long orderId) {
        UserInfo userInfo = UserThreadLocal.get();
        QueryWrapper queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("company_id",userInfo.getCompanyId());
        queryWrapper.eq("order_id",orderId);
        List<VProductionPlanDetail> list = list(queryWrapper);
        return list;
    }

    @Override
    public void removeByOrderId(Long orderId) {
        baseMapper.removeByOrderId(orderId);
    }
}
